package com.dhcc.client.api;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dhcc.entity.GatewayRequest;
import com.dhcc.entity.GatewayResponse;
import com.google.gson.reflect.TypeToken;

public class GatewayClientApi {
    private ApiClient localVarApiClient;

    public GatewayClientApi() {
        this(Configuration.getDefaultApiClient());
    }

    public GatewayClientApi(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public GatewayClientApi(String url) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath(url);
        this.localVarApiClient = defaultClient;
    }
    
    public ApiClient getApiClient() {
        return localVarApiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    /**
     * Build call for request
     * @param GatewayRequest request (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="GatewayResponse Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> GatewayResponse Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call requestCall(GatewayRequest request, final ApiCallback _callback, String method, String httpMethod) throws ApiException {
        Object localVarPostBody = request;

        // create path and map variables
        String localVarPath = method;

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "*/*"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] {  };
        return localVarApiClient.buildCall(localVarPath, httpMethod, localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call requestValidateBeforeCall(GatewayRequest request, final ApiCallback _callback, String method, String httpMethod) throws ApiException {
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling request(Async)");
        }
        

        okhttp3.Call localVarCall = requestCall(request, _callback, method, httpMethod);
        return localVarCall;

    }

    /**
     * request
     * 
     * @param GatewayRequest request (required)
     * @return GatewayResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="GatewayResponse Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> GatewayResponse Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public GatewayResponse request(GatewayRequest request, String method, String httpMethod) throws ApiException {
        ApiResponse<GatewayResponse> localVarResp = requestWithHttpInfo(request, method, httpMethod);
        return localVarResp.getData();
    }

    /**
     * request
     * 
     * @param request request (required)
     * @return ApiResponse&lt;GatewayResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="GatewayResponse Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> GatewayResponse Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<GatewayResponse> requestWithHttpInfo(GatewayRequest request, String method, String httpMethod) throws ApiException {
        okhttp3.Call localVarCall = requestValidateBeforeCall(request, null, method, httpMethod);
        Type localVarReturnType = new TypeToken<GatewayResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * request (asynchronously)
     * 
     * @param request request (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="GatewayResponse Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> GatewayResponse Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call requestAsync(GatewayRequest request, final ApiCallback<GatewayResponse> _callback, String method, String httpMethod) throws ApiException {

        okhttp3.Call localVarCall = requestValidateBeforeCall(request, _callback, method, httpMethod);
        Type localVarReturnType = new TypeToken<GatewayResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    
  /**
     * Build call for getPublic
     * @param request request (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Map<String, String> Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Map<String, String> Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getPublicCall(Map<String, String> request, final ApiCallback _callback, String method) throws ApiException {
        Object localVarPostBody = request;

        // create path and map variables
        String localVarPath = method;

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "*/*"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] {  };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getPublicValidateBeforeCall(Map<String, String> request, final ApiCallback _callback, String method) throws ApiException {
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling getPublic(Async)");
        }
        

        okhttp3.Call localVarCall = getPublicCall(request, _callback, method);
        return localVarCall;

    }

    /**
     * getPublic
     * 
     * @param request request (required)
     * @return Map<String, String>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Map<String, String> Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Map<String, String> Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public Map<String, Object> getPublic(Map<String, String> request, String method) throws ApiException {
        ApiResponse<Map<String, Object>> localVarResp = getPublicWithHttpInfo(request, method);
        return localVarResp.getData();
    }

    /**
     * getPublic
     * 
     * @param request request (required)
     * @return ApiResponse&lt;Map<String, String>&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Map<String, String> Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Map<String, String> Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Map<String, Object>> getPublicWithHttpInfo(Map<String, String> request, String method) throws ApiException {
        okhttp3.Call localVarCall = getPublicValidateBeforeCall(request, null, method);
        Type localVarReturnType = new TypeToken<Map<String, String>>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * getPublic (asynchronously)
     * 
     * @param request request (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Map<String, String> Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Map<String, String> Headers </td></tr>
        <tr><td> 200 </td><td> OK </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> Not Found </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getPublicAsync(Map<String, String> request, final ApiCallback<Map<String, String>> _callback, String method) throws ApiException {

        okhttp3.Call localVarCall = getPublicValidateBeforeCall(request, _callback, method);
        Type localVarReturnType = new TypeToken<Map<String, String>>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    
}
